package com.example.text.ui.mall.view

import android.content.Context
import android.util.AttributeSet
import android.widget.FrameLayout

//
//
//
//import android.content.Context
//import android.media.Image
//import android.util.AttributeSet
//import android.view.LayoutInflater
//import android.view.ViewGroup
//import android.widget.FrameLayout
//import android.widget.ImageView
//import androidx.recyclerview.widget.GridLayoutManager
//import androidx.recyclerview.widget.LinearLayoutManager
//import androidx.recyclerview.widget.RecyclerView
//import androidx.recyclerview.widget.SimpleItemAnimator
//import com.example.text.R
//import com.example.text.ui.mall.adepter.EvaluationListMultiAdapter
//import com.example.text.ui.mall.adepter.EvaluationNinePicsAdapter
//import com.example.text.ui.mall.model.Info
//
////import com.bm.library.Info
////import com.bm.library.PhotoView
////import com.jczy.cyclone.R
////import com.jczy.cyclone.model.Image
////import com.jczy.cyclone.ui.mall.adapter.EvaluationListMultiAdapter
//
///**
// *@author Wcj
// *@description
// *@date 2022/7/5 14:50
// */
class EvaluationNineGridPicsView : FrameLayout {
//    private val mParentView: ViewGroup
//    private var itemType: Int = 0
//    private val mRvPic: RecyclerView
//    private var mPicsList: List<Image>? = null
//    private var mFullList: List<Image>? = null
//    private var onItemClickListener: ((Int, Int, List<String>, List<Info>?) -> Unit)? = null
//
    constructor(context: Context) : this(context, null)
    constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
//        mParentView = LayoutInflater.from(context).inflate(R.layout.layout_nine_grid_pics_view, this) as ViewGroup
//        mRvPic = mParentView.findViewById(R.id.rv_pic_9)
    }
//
//    // 设置图片显示列表
//    fun setPicsList(itemType: Int, list: List<Image>, fullList: List<Image>? = null) {
//        this.itemType = itemType
//        this.mPicsList = list
//        this.mFullList = fullList
//    }
//
//    //设置点击事件
//    fun setOnItemClickListener(l: (Int, Int, List<String>, List<Info>?) -> Unit) {
//        this.onItemClickListener = l
//    }
//
//    //初始化View //增加点击空白处的事件
//    fun initView(position: Int, onClickEmptyArea: (() -> Unit)? = null) {
//        if (mPicsList == null) {
//            return
//        }
//        val urlList = if (mFullList != null) mFullList!!.map { it.url } else mPicsList!!.map { it.url }
//        val lg = when (itemType) {
//            EvaluationListMultiAdapter.TYPE_1V1P -> {
//                GridLayoutManager(context, 1, RecyclerView.VERTICAL, false)
//            }
//            EvaluationListMultiAdapter.TYPE_1V2P -> {
//                GridLayoutManager(context, 1, RecyclerView.VERTICAL, false)
//            }
//            EvaluationListMultiAdapter.TYPE_0V4P -> {
//                // GridLayoutManager(context, 4, RecyclerView.VERTICAL, false)
//                LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
//            }
//            EvaluationListMultiAdapter.TYPE_AFTER_DETAIL -> {
//                var spanSize = mPicsList!!.size
//                if (spanSize > 3) spanSize = 3
//                GridLayoutManager(context, spanSize, RecyclerView.VERTICAL, false)
//            }
//            else -> {
//                GridLayoutManager(context, if (mPicsList!!.size == 1) 1 else if (mPicsList!!.size == 2) 3 else 3, RecyclerView.VERTICAL, false)
//            }
//        }
//        mRvPic.layoutManager = lg
//        (mRvPic.itemAnimator as SimpleItemAnimator).supportsChangeAnimations = false
//        val ninePicsAdapter = EvaluationNinePicsAdapter(itemType, mPicsList!!) {
////            val imageInfo = mutableListOf<Info>()
////            repeat(mPicsList!!.size) { pos ->
//////                try {
////                val root = lg.findViewByPosition(pos)
////                if (root is ImageView) {
////                    imageInfo.add(PhotoView.getImageViewInfo(root))
////                } else {
////                    val iv = root?.findViewById<ImageView>(R.id.iv_pic)
////                    if (iv != null)
////                        imageInfo.add(PhotoView.getImageViewInfo(iv))
////                }
//////                } catch (e: Exception) {
//////                    imageInfo.add(Info(0, 0, 0))
//////                }
////            }
//            onItemClickListener?.invoke(position, it, urlList, null)
//        }
//
//        mRvPic.adapter = ninePicsAdapter
//        repeat(mRvPic.childCount) {
//            PhotoView.getImageViewInfo(mRvPic.getChildAt(it) as ImageView)
//            mRvPic.getChildAt(it).setOnClickListener {
//            }
//        }
////        RecyclerMarginClickHelper.setOnMarginClickListener(mRvPic) {
////            onClickEmptyArea?.invoke()
////        }
//
//    }
}